package com.ruoyi.web.controller.fs;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fs.domain.FsTodoList;
import com.ruoyi.fs.service.IFsTodoListService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 代办事项Controller
 * 
 * @author hero
 * @date 2024-09-09
 */
@RestController
@RequestMapping("/fs/todoList")
public class FsTodoListController extends BaseController
{
    @Autowired
    private IFsTodoListService fsTodoListService;

    /**
     * 查询代办事项列表
     */
    @PreAuthorize("@ss.hasPermi('fs:todoList:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsTodoList fsTodoList)
    {
        startPage();
        List<FsTodoList> list = fsTodoListService.selectFsTodoListList(fsTodoList);
        return getDataTable(list);
    }

    /**
     * 导出代办事项列表
     */
    @PreAuthorize("@ss.hasPermi('fs:todoList:export')")
    @Log(title = "代办事项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FsTodoList fsTodoList)
    {
        List<FsTodoList> list = fsTodoListService.selectFsTodoListList(fsTodoList);
        ExcelUtil<FsTodoList> util = new ExcelUtil<FsTodoList>(FsTodoList.class);
        util.exportExcel(response, list, "代办事项数据");
    }

    /**
     * 获取代办事项详细信息
     */
    @PreAuthorize("@ss.hasPermi('fs:todoList:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fsTodoListService.selectFsTodoListById(id));
    }

    /**
     * 新增代办事项
     */
    @PreAuthorize("@ss.hasPermi('fs:todoList:add')")
    @Log(title = "代办事项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsTodoList fsTodoList)
    {
        return toAjax(fsTodoListService.insertFsTodoList(fsTodoList));
    }

    /**
     * 修改代办事项
     */
    @PreAuthorize("@ss.hasPermi('fs:todoList:edit')")
    @Log(title = "代办事项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsTodoList fsTodoList)
    {
        return toAjax(fsTodoListService.updateFsTodoList(fsTodoList));
    }

    /**
     * 删除代办事项
     */
    @PreAuthorize("@ss.hasPermi('fs:todoList:remove')")
    @Log(title = "代办事项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsTodoListService.deleteFsTodoListByIds(ids));
    }
}
